package com.yyt.yytcodesandbox.unsafe;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

public class RunFileError {
    public static void main(String[] args) throws IOException, InterruptedException {
        String property = System.getProperty("user.dir");
        String filePath = property + File.separator + "src/main/resources/muma.bat";
        Process process = Runtime.getRuntime().exec(filePath);
        int exitValue = process.waitFor();
        if(exitValue==0){
            System.out.println("运行成功");
            //分批获得进程的信息
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            StringBuilder stringBuilder=new StringBuilder();
            String outputLine;
            while((outputLine= bufferedReader.readLine())!=null){
                stringBuilder.append(outputLine);
            }
            System.out.println(stringBuilder);
        }
    }
}
